$(function(){
	checkLog();
	loadGuide(true);
	createBarBread([{title:"首页",url:indexUrl},{title:"我的小说"}]);
	baseLoad();
	$.ajax({
		url:APIURL + "/Novel/getNovelListWeb.php",
		data:"userId=" + userId(),
		success:function(data){
			hideBaseLoad();
			data = $.parseJSON(data);
	        if(data.status != "FAILED"){
	        	if(!data.value || !data.value.length){
		          	if(getCLientType() == "lovenovel"){
			        	$(".nobooktip .item").hide().eq(1).show();
		          	}
	        		$(".nobooktip").show();
	        	}else{
					successHandle(data) 	        		
	        	}
                       
	        }else{
	          layer.open({
	              content: data.value,
	              time: 1
	          }); 
	        }
		},
		error:function(err){
			hideBaseLoad();
			layer.open({
				content:err.value || err_txt,
				time:2
			})
		}
	})

	function successHandle(data){
		var str = "";
		var datalist = data.value;
		for(var i = 0,len = datalist.length; i < len ; i++){
			var converUrl = datalist[i].coverUrl || "img/test-img.jpg";
			str += '<a href="javascript:;" data-id="'+datalist[i].id+'" data-name="'+datalist[i].name+'" data-publishid="'+datalist[i].publishId+'">'+
						'<img src="'+converUrl+'" alt="">'+
						'<span class="ellipsis_1" title="'+datalist[i].name+'">'+datalist[i].name+'</span>'+
					'</a>';
		}
		$(".mybooklist").html(str);
	}

	$(".mybooklist").on("click","a",function(){
		localStorage.setItem("pageparam_detail",'bookid='+$(this).attr("data-id")+'&bookname='+$(this).attr("data-name")+'&publishbookid='+$(this).attr("data-publishid"));
		window.location.href = "mybook-detail.html";
	})

	$("#edit_continue").on("click",function(){
		var param = localStorage.getItem("record_edit_param");
		var recordType = localStorage.getItem("record_type");
		if(recordType == "edit"){
			localStorage.setItem("edit_mark","edit");
			localStorage.setItem("pageparam_edit",param);
			window.location.href = "mybook-chapter-edit.html";				
		}else{
	        layer.open({
	            content:"您还没有在该浏览器编辑过，或者上次编辑记录已清除",
	            time: 3
	        });
		}
	})
})